package expression

import (
	"cdam/qiniu/qlang"
)

type pairs struct {
	Key   string
	Value string
}

type expContext struct {
	predefined
	ql  *qlang.Qlang
	err error
}

func qlangFromContext(ctx ExpContext) *qlang.Qlang {
	ql, ok := ctx.(*expContext)
	if ok {
		return ql.ql
	}
	return nil
}

func (e *expContext) Var(key string) interface{} {
	return e.ql.Var(key)
}

func (e *expContext) AddVar(key string, value interface{}) {
	// e.PredefinedVar(key,value.(string))
	e.ql.SetVar(key, value)
}

func CreateExpContext() ExpContext {
	return &expContext{
		ql:         qlang.New(),
		predefined: predefined{data: make([]pairs, 0, 4)},
	}
}
